﻿using System.Collections.Generic;
using YAXLib;

namespace RaytracerLib.Layers
{
    public abstract class UnaryLayer : Layer
    {
        private Layer m_child_layer;

        protected UnaryLayer(Layer a_childLayer)
        {
            ChildLayer = a_childLayer;
        }

        public override IEnumerable<Layer> Children
        {
            get
            {
                yield return ChildLayer;
            }
        }

        [YAXNode("Layer")]
        public Layer ChildLayer
        {
            get
            {
                return m_child_layer;
            }
            set
            {
                if (m_child_layer != null)
                    m_child_layer.Parent = null;
                m_child_layer = value;
                if (m_child_layer != null)
                    m_child_layer.Parent = this;
            }
        }
    }
}